<?php

/*
 * Copyright by Sygma Media Inovasi Ω2013
 * 
 * Lead Programmer : Sony K Wibisono,S.Si,M.T.I
 * E-mail : sony@sonywibisono.com
 * 
 *  
 * 
 */
function _add(){
    
}
function _edit(){
    global $db,$id;
}
function _add_process(){
    global $db;
}
function _edit_process(){
    global $db;
}
function _delete(){
    global $db,$id;
}
function get_max_page(){
    global $db,$pagesize;
    $sql="select count(*) from [table_name]";
    $row=$db->fetch_row($sql);
    if (!empty($row)){
        return floor($row[0]/$pagesize)+1;
    } else return 0;
}
function _default(){
    global $db,$username,$password;
    if (!empty($username)){
        $sql="select * from users where username='$username'";
        $row=$db->fetch_row($sql);
        if (!empty($row)){
            if ($row['password']==$password){
                $_SESSION['user_name']=$username;
                $_SESSION['is_login']=true;
                 refresh_to("?mod=admin", "Login Benar, ke Halaman Administrator", 2);
            } else {
                $_SESSION['user_name']="guest";
                $_SESSION['is_login']=false;
                refresh_to("?mod=admin", "Login Salah, silakan coba lagi", 2);
            }
        }
    } else {
        message_box("Kesalahan","Nama User tidak boleh blank");
    }
     
}
 
global $action;
switch($action){
    case 'add':
        _add();
        break;
    case 'add_process':
        _add_process();
        break;
    case 'edit':
        _edit();
        break;
    case 'edit_process':
        _edit_process();
        break;
    case 'delete':
        _delete();
        break;
    case 'login':
    default :
        _default();
}
?>
